
<template>
    <rx-dialog @handOk="handleSubmit" @cancel="cancel">
        <rx-layout>
            <div slot="center">
                <a-form-model ref="form"  :model="mdl" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
                    <a-row>
                        <a-col :span="12">
                            <a-form-model-item  :label="i18n('form.name','变量名')" prop = "name">
                                <a-input :placeholder="i18n('form.name','变量名','input')" v-model="mdl.name"/>
                            </a-form-model-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-model-item  :label="i18n('form.value','变量值')" prop = "value">
                                <a-input :placeholder="i18n('form.value','变量值','input')" v-model="mdl.value"/>
                            </a-form-model-item>
                        </a-col>
                    </a-row>
                    <a-row>
                        <a-col :span="12">
                            <a-form-model-item  :label="i18n('form.isEdit','是否编辑')" prop = "isEdit">
                                <a-switch v-model="isEdit"/>
                            </a-form-model-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-model-item  :label="i18n('form.enabled','是否启用')" prop = "enabled">
                                <a-switch v-model="enabled"/>
                            </a-form-model-item>
                        </a-col>
                    </a-row>
                    <a-row>
                        <a-col :span="24">
                            <a-form-model-item  :label="i18n('form.desc','变量备注')" prop = "desc" :label-col="labelCol1" :wrapper-col="wrapperCol1">
                                <rx-input-i18n :placeholder="i18n('form.desc','请输入变量备注','input')" v-model="mdl.desc"></rx-input-i18n>
<!--                                <a-textarea :rows="4" :placeholder="i18n('form.desc','请输入变量备注','input')" v-model="mdl.desc"/>-->
                            </a-form-model-item>
                        </a-col>
                    </a-row>
                    <a-row>
                        <a-col :span="24">
                            <a-form-model-item  :label="$ti18('rxList.index','序号')" prop = "sn" :label-col="labelCol1" :wrapper-col="wrapperCol1">
                                <a-input-number :min="1" v-model="mdl.sn" />
                            </a-form-model-item>
                        </a-col>
                    </a-row>
                </a-form-model>
            </div>
        </rx-layout>
    </rx-dialog>
</template>
<script>
    import FormCodegenVariableApi from '@/api/form/codegen/formCodegenVariable'
    import {RxDialog,BaseFormModel} from "@lowcode/jpaas-common-lib";

    export default {
        name: 'FormCodegenVariableEdit',
        mixins: [BaseFormModel],
        components: {
            RxDialog,
        },
        data() {
            return {
                mdl:{
                    sn:1
                },
                isEdit:false,
                enabled:false,
                rules: {
                    name: [{required: true, message: this.i18n('form.name','请输入变量名','input'), trigger: 'change'}],
                    value: [{required: true, message: this.i18n('form.value','请输入变量值','input'), trigger: 'change'}],
                    desc:[{required: true, message: this.i18n('form.desc','请输入变量备注','input'), trigger: 'change'}]
                }
            }
        },
        methods: {
            i18n(name,text,key){
                return this.$ti18(name,text,"formCodegenVariable",key);
            },
            onload_(data){
                if(data){
                    this.isEdit=data.isEdit=='YES'?true:false;
                    this.enabled=data.enabled=='YES'?true:false;
                }
            },
            get(id) {
                return FormCodegenVariableApi.get(id);
            },
            save() {
                this.mdl.isEdit=this.isEdit?'YES':'NO';
                this.mdl.enabled=this.enabled?'YES':'NO';
                return FormCodegenVariableApi.save(this.mdl);
            }
        }
    }
</script>
<style>
    .relick a{
        margin-right: 10px;
    }

</style>
